package 字节;


import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main_0918_1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        LinkedList<int[]> list=new LinkedList<>();
        long res=0;
        for (int i = 0; i < n; i++) {
            int m=cin.nextInt();
            if (i==0){
                res+=m;
            }
            int[] line=new int[m];
            for (int j = 0; j < m; j++) {
                line[j]=cin.nextInt();
            }
            list.add(line);
        }
        for (int i = 1; i < n; i++) {
            int[] line=list.get(i);
            int[] low=list.get(i-1);
            for (int j = 0; j < line.length; j++) {
                int cur=line[j];
                int lowIndex=0;
                while (lowIndex<low.length&&(low[lowIndex]==-1||cur>low[lowIndex]+100||cur+100<low[lowIndex])){
                    //无重叠
                    lowIndex++;
                }
                if (lowIndex<low.length&&low[lowIndex]==cur){
                    res++;
                }else if (lowIndex<low.length&&low[lowIndex]!=-1&&cur<low[lowIndex]+100&&lowIndex+1<low.length&&low[lowIndex+1]!=-1&&cur+100>low[lowIndex+1]){
                    //和两块都有重叠
                    res++;
                }else if (lowIndex<low.length&&low[lowIndex]!=-1&&((cur>low[lowIndex]&&cur+50<low[lowIndex]+100)||cur+100>low[lowIndex]&&cur+50>low[lowIndex])) {

                    //重心可以支撑
                    res++;
                }else {
                        //完全无法支撑
                        line[j]=-1;
                    }
                }
            }

        System.out.println(res);
    }
}
